import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components'

import './index.less'

type IGraphicsElementType = {
  content: string,
  link: string,
  type: string
}

type IGraphicsProps = {
  descriptionsMiniList: IGraphicsElementType[]
}

export default class Graphics extends Component<IGraphicsProps, {}> {

  static defaultProps = {
    descriptionsMiniList: []
  }

  render () {
    const { descriptionsMiniList = [] } = this.props
    return (
      <View className='container'>
        {
          descriptionsMiniList.map((item, index) => {
            return (
              item.type == 'IMAGE' ? (
                <Image src={item.content} lazyLoad mode='widthFix' className='cell-item cell-item_img' key={index} />
              ) : (item.type == 'TEXT' ? (
                  <View className='cell-item' key={index}>{item.content}</View>
                ) : null)
            )
          })
        }
      </View>
    )
  }
}
